<?php if(!IS_AJAX){?>

<include file="Public:header" />
<div class="row">
    <div class="col-sm-7 col-md-8 col-lg-9">
        <div class="directory-info-row" style="margin-top:0;">
            <section class="panel">
                <div class="panel-heading"><span class="pagetitle">积分详情</span></div>
                <div class="panel-body">
                    <div id="container" style="min-width:100%;height:300px"> </div>
                    <div class="tab-content">
                        <div class="tab-pane active " id="home">
                            <table class="table  table-hover general-table table-custom table-striped">
                                <thead>
                                <tr>
                                    <th>名称</th>
                                    <th>分类</th>
                                    <th class="visible-lg">介绍</th>
                                    <th>积分</th>
                                    <th>类型</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="ajaxlistbox">
                                <?php }?>
                                <!------------------------ 数据主体-------------------------- -->
                                <volist name="list" id="vo">
                                    <tr id="ajaxlistbox-{$vo.id}" class="DataListItem DataListItembg">
                                        <td title="{$vo.name}"><div class="big_td">{$vo.name}</div></td>
                                        <td title="{$vo.type_name}"><div class="limit_h_36">{$vo.type_name}</div></td>
                                        <td title="{$vo.remark}" class="visible-lg"><div class="big_td">{$vo.remark}</div></td>
                                        <td class="text-{:$vo['integralnum']>0?'success':'danger'}">{$vo.integralnum}</td>
                                        <td>{$vo.integralTypeName}</td>
                                        <td class="optionBtnBox">
                                            <!--增加权限控制2016-11-29 by：zmx-->
                                            <if condition="getAccessMenu($accessList, 'Intesys', 'Integral_rule', 'edit')"> <a class="OptionBtn" href="javascript:void(0);"  rel="<?php echo U('edit',['id'=>$vo['id']]) ?>" title="修改规则" width="650" > <i class="fa icon-edit text-info"></i> </a> </if>

                                            <!--增加权限控制2016-11-29 by：zmx-->

                                            <if condition="getAccessMenu($accessList, 'Intesys', 'Integral_rule', 'delete')"> <a class="button deleteBtn" data-id="{$vo.id}" href="javascript:void(0);" rel="<?php echo U('delete',['id'=>$vo['id']]) ?>" title="删除规则"> <i class="fa icon-trash-o text-danger"></i> </a> </if></td>
                                    </tr>
                                </volist>
                                <!------------------------ 数据主体结束---------------------- -->
                                <?php if(!IS_AJAX){?>
                                </tbody>
                            </table>
                            <div class="loading hidden">正在加载</div>
                            <div id="ajaxlistboxpages" style="text-align:center;"><?php echo $pages; ?></div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
    <div class="col-sm-5 col-md-4 col-lg-3">

        <div class="affixelement">
            <div class="states-info">
                <!--增加权限控制2016-11-29 by：zmx-->
                <if condition="getAccessMenu($accessList, 'Intesys', 'Integral_rule', 'add')">
                    <div class="panel green-bg" style="cursor:pointer" onClick="_openWindow('<?php echo U('add') ?>',650,'新建积分规则','提交',null);">
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-xs-3"> <i class="fa icon-bar-chart-o"></i> </div>
                                <div class="col-xs-7">
                                    <h4>新建积分规则</h4>
                                    <span class="state-title">为公司建立新的积分规则</span> </div>
                                <div class="col-xs-2"> <span class="fa icon-angle-right"></span> </div>
                            </div>
                        </div>
                    </div>
                </if>
            </div>
            <form action="<?php echo U('index');?>" id="ajaxlistboxform">
                <div class="panel">
                    <header class="panel-heading"> 规则搜索 </header>
                    <div class="panel-body">
                        <div class="input-group m-bot15">
                            <input type="text" name="keywords" class="form-control">
          <span class="input-group-btn">
          <button type="button" onClick="$('#ajaxlistboxform').submit();" class="btn btn-default"><i class="fa icon-search" style="font-size:16px"></i></button>
          </span> </div>
                        <!--<input type="hidden" name="type_id" value="">-->
                        <div id="integralcategoryvar"> </div>
                    </div>
                </div>
                <div class="panel">
                    <header class="panel-heading"> 规则分类 <span class="pull-right">
      <!--增加权限控制2016-11-29 by：zmx-->
      <if condition="getAccessMenu($accessList, 'Intesys', 'Integral_ruletype', 'add')"> <a href="javascript:void(0);" onClick="_openWindow('<?php echo U('Integral_ruletype/add') ?>',650,'新建积分规则分类','提交',function(){treeObj.reAsyncChildNodes(null, 'refresh');});" rel="<?php echo U('Integral_ruletype/add');?>" width="300" title="新增规则分类">增加分类</a> </if>
      </span> </header>
                    <div class="panel-body">
                        <div class="membertreebox"></div>
                        <div class="ztree" id="membertree"></div>

                        <!-- 规则分类 -->
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tbody id="integralcategorybox">
                            </tbody>
                        </table>
                        <div id="integralcategoryboxpages"></div>
                        <form action="<?php echo U('IntegralCategory/index');?>" id="integralcategoryboxform">
                        </form>
                    </div>
                </div>
            </form>
            <div class="panel panel-rightMenu">
                <ul class="list-unstyled">
                    <li class="treeEdit" rel="<?php echo U('Integral_ruletype/edit'); ?>">修改分类</li>
                    <li class="treeAdd" rel="<?php echo U('Integral_ruletype/addChild'); ?>">添加子集</li>
                    <li class="treeDelete" rel="<?php echo U('Integral_ruletype/delete'); ?>">删除</li>
                </ul>
            </div>
            <style>
                .panel-rightMenu{ box-shadow:4px 4px 5px rgba(0,0,0,0.2); border:1px solid #ddd; border-radius:2px;position: fixed;width: 250px; z-index:999; color:#333; display:none;}
                .panel-rightMenu li{ padding-left:20px; padding-top:6px; padding-bottom:6px; font-size:12px;}
                .panel-rightMenu li:hover{ background:#eee; cursor:pointer;}
            </style>
        </div>
    </div>
</div>
<include file="Public:script" />
<script src="__PUBLIC__/Js/highcharts.src.js"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Js/zTree_v3/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="/Public/Js/zTree_v3/js/jquery.ztree.core-3.5.js"></script>
<script>
    $(function () {
        $('#container').highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {text: '积分管理系统积分规则'},
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: false
                    },
                    showInLegend: true
                }
            },
            series: [{type: 'pie',name: '规则分数占比',data: [['产值/项目',66],['能力分',10],['综合表现',24]]}]
        });
    });
    $('#ajaxlistbox').ajaxlist();
    //当鼠标离开菜单的时候 移除样式

    $(".panel-rightMenu").mouseleave(function(e) { $(this).removeAttr("style"); });
    var settingbefore = {
        view: {selectedMulti: false,addDiyDom:addDiyDom},
        async: {
            enable: true,
            url:"{:U('Integral_ruletype/ruletypeTree')}",
            autoParam:["id", "name=n", "level=lv"],
            otherParam:{"otherParam":"zTreeAsyncTest"},
            dataFilter: fillup
        },
        callback: {
            beforeClick: Clickbefore,
            beforeAsync: Asyncbefore,
            onRightClick:onRightClick,
            onAsyncError: ErroronAsync,
            onAsyncSuccess: SuccessonAsync
        }
    };
    function fillup(treeId, parentNode, childNodes) {
        if (!childNodes) return null;
        for (var i=0, l=childNodes.length; i<l; i++) {
            childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');
        }
        return childNodes;
    }
    //当右键点击的时候，显示菜单和邦定相应的事件
    function onRightClick(treeId,treeNode){
        var dataId=$(treeId.target).find(".treeData").attr('data-id');
        var dataTId=$(treeId.target).find(".treeData").attr('data-tid');
        var nodes = treeObj.getNodeByTId(dataTId).getParentNode();
        var pNodes=nodes?nodes.getParentNode():nodes;
        var span=$("#"+dataTId+"_span");
        $(".panel-rightMenu").css({'left':treeId.clientX*1-4,'top':treeId.clientY*1-4,'display':'block'});
        $(".panel-rightMenu .treeAdd").unbind("click");
        $(".panel-rightMenu .treeEdit").unbind("click");
        //当点击‘添加子集’的时候
        $(".panel-rightMenu .treeAdd").click(function(e) {
            var url=$(this).attr('rel')+'&id='+dataId;
            _openWindow(url,650,'新建积分规则分类','提交',function(){//弹出窗口
                treeObj.reAsyncChildNodes(nodes, "refresh",'false');//刷新修改了的节点
            });
        });
        //当点击‘修改分类’的时候
        $(".panel-rightMenu .treeEdit").click(function(e) {
            var url=$(this).attr('rel')+'&id='+dataId;
            //弹出窗口
            _openWindow(url,650,'修改积分规则分类','提',function(){
                //获取修改后的数据
                $.getJSON('{:U('Integral_ruletype/getInfo')}',{id:dataId},function(data){
                    var pNodes2=treeObj.getNodesByParam('id',data.info['pid'],null)[0];
                    pNodes2=pNodes2['getParentNode']?pNodes2.getParentNode():pNodes2;
                    //刷新修改前的父节点和修改后的父节点
                    treeObj.reAsyncChildNodes(pNodes2,"refresh",'false');
                    if(pNodes!=pNodes2){
                        treeObj.reAsyncChildNodes(pNodes, "refresh");
                    }
                });
            });
        });
        //当点击‘删除’的时候
        $(".panel-rightMenu .treeDelete").click(function(e) {
            var url=$(this).attr('rel');
            $.getJSON(url,{'id':dataId},function(data){
                if(data.statu==0){
                    artDialog({content:data.info})
                }else{
                    treeObj.reAsyncChildNodes(nodes, "refresh",'false');
                }
            });
        });
    }
    function addDiyDom(treeId,treeNode){
        $("<i>").addClass("treeData").attr({'data-id':treeNode.id,'data-tId':treeNode.tId}).appendTo($('#'+treeNode.tId+'_span'));
    }
    function Clickbefore(treeId, treeNode) {
        var html = '<div id="member_pos_id'+treeNode.id+'" class="alert member_pos_id alert-info fade in" style="display:inline-block; margin-bottom:2px; margin-right:2px; padding:5px;"><button type="button" class="close close-sm" onclick="$(this).parent().remove();$(\'#ajaxlistboxform\').submit();" data-dismiss="alert"> <i class="fa icon-times"></i> </button><strong><input type="hidden" value="'+treeNode.id+'" name="type_id" class="NodeId" />'+treeNode.name+'</strong> </div>';
        $('.member_pos_id').remove();
        $(html).appendTo('.membertreebox');
        $('#ajaxlistboxform').submit();
        if (!treeNode.isParent) {
            return false;
        } else {
            return true;
        }
    }
    var className = "dark";
    function Asyncbefore(treeId, treeNode) {
        className = (className === "dark" ? "":"dark");
        return true;
    }
    function ErroronAsync(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) { }
    function SuccessonAsync(event, treeId, treeNode, msg) { }

    $.fn.zTree.init($("#membertree"), settingbefore);
    var treeObj = $.fn.zTree.getZTreeObj("membertree");
</script>
<style>
    #integralcategorybox td{padding:5px;}
    .limit_h_36{ height:36px; overflow:hidden;}
</style>
</body></html><?php }?>